/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package clusterAnalysis;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import utils.FileUtils;

/**
 *
 * @author jamie
 */
public class MinetReader {

    private int[] probeIds;
    private double[][] minetValues;
    
    public void readFile(File minetFile) throws IOException{
        BufferedReader reader = FileUtils.getBufferedReader(minetFile);
        String line = reader.readLine();
        probeIds = getProbeIds(line);
        int i=0;
        minetValues = new double[probeIds.length][];
        while((line = reader.readLine())!=null){
            String[] split = line.split("\t");
            minetValues[i] = getValues(split);
            i++;
        }
//        System.out.println(minetValues.length+", "+minetValues[0].length);
    }

    private int[] getProbeIds(String line) {
        String[] split = line.split("\t");
        int[] ids = new int[split.length];
        for(int i=0;i<split.length;i++){
            ids[i] = Integer.parseInt(split[i].substring(1));
        }
        return ids;
    }

    private double[] getValues(String[] split) {
        double[] values = new double[probeIds.length];
        int j=0;
        for(String s : split){
            if(j>0){
                values[j-1] = Double.parseDouble(s);
            }
            j++;
        }
        return values;
    }

    public double[][] getMinetValues() {
        return minetValues;
    }

    public int[] getProbeIds() {
        return probeIds;
    }

    





}
